/************************************************************************

								Heroes IV
					  Copyright 2000, The 3DO Company

	------------------------------------------------------------------
  						       hero_portrait.h

	$Header: /game/hero_portrait.h $

	$NoKeywords: $

 ************************************************************************/

// kill the 255+ character identifier warning.  Templates tend to exceed that easily.
#include "precompiled.h"
#pragma warning( disable: 4786 )

#include "hero_portrait.h"

#include "bitmap_group_cache.h"
#include "bitmap_pool.h"
#include "elements_of.h"
#include "town_type.h"

namespace 
{
	t_bitmap_group_cache g_bitmap_cache[] =
	{
		"portraits.life.52",
		"portraits.order.52",
		"portraits.death.52",
		"portraits.chaos.52",
		"portraits.nature.52",
		"portraits.might.52" 
	};

	t_bitmap_group_cache g_bitmap_82_cache[] =
	{
		"portraits.life.82",
		"portraits.order.82",
		"portraits.death.82",
		"portraits.chaos.82",
		"portraits.nature.82",
		"portraits.might.82" 
	};


	t_char_ptr_pair const k_definitions[] =
	{
		// WARNING: Add only to the END of this array
		{ k_town_chaos, "aidan" },
		{ k_town_chaos, "ajit" },
		{ k_town_chaos, "ajwar" },
		{ k_town_chaos, "althea" },
		{ k_town_chaos, "andria" },
		{ k_town_chaos, "atella" },
		{ k_town_chaos, "calistar" },
		{ k_town_chaos, "charzir" },
		{ k_town_chaos, "dace" },
		{ k_town_chaos, "darkstorm" },
		{ k_town_chaos, "devin" },
		{ k_town_chaos, "Flaren" },
		{ k_town_chaos, "flaym" },
		{ k_town_chaos, "Gretchin" },
		{ k_town_chaos, "gruezak" },
		{ k_town_chaos, "gundross" },
		{ k_town_chaos, "hafir" },
		{ k_town_chaos, "helice" },
		{ k_town_chaos, "Hoogula" },
		{ k_town_chaos, "iboz" },
		{ k_town_chaos, "isa" },
		{ k_town_chaos, "jael" },
		{ k_town_chaos, "jeddite" },
		{ k_town_chaos, "kardd" },
		{ k_town_chaos, "kaspar" },
		{ k_town_chaos, "kineta" },
		{ k_town_chaos, "lorelei" },
		{ k_town_chaos, "maddox" },
		{ k_town_chaos, "madmarik" },
		{ k_town_chaos, "mastero" },
		{ k_town_chaos, "mayweda" },
		{ k_town_chaos, "mered" },
		{ k_town_chaos, "nazibar" },
		{ k_town_chaos, "nefafareen" },
		{ k_town_chaos, "norzok" },
		{ k_town_chaos, "octavia" },
		{ k_town_chaos, "pythia" },
		{ k_town_chaos, "rana" },
		{ k_town_chaos, "ritzil" },
		{ k_town_chaos, "rufus" },
		{ k_town_chaos, "sephinroth" },
		{ k_town_chaos, "sizz" },
		{ k_town_chaos, "tacitia" },
		{ k_town_chaos, "ungoliant" },
		{ k_town_chaos, "valynne" },
		{ k_town_chaos, "xyron" },
		{ k_town_chaos, "yorpix" },
		{ k_town_chaos, "yoru" },

		{ k_town_death, "aglion"	},
		{ k_town_death, "aislinn"	},
		{ k_town_death, "archilus"	},
		{ k_town_death, "arkenvoss"	},
		{ k_town_death, "ash"	},
		{ k_town_death, "ayden"	},
		{ k_town_death, "calh"	},
		{ k_town_death, "castrata"	},
		{ k_town_death, "charna"	},
		{ k_town_death, "damala"	},
		{ k_town_death, "docata"	},
		{ k_town_death, "draezerak"	},
		{ k_town_death, "endan"	},
		{ k_town_death, "felina"	},
		{ k_town_death, "fiona"	},
		{ k_town_death, "gargareen"	},
		{ k_town_death, "grok"	},
		{ k_town_death, "harkenraz"	},
		{ k_town_death, "hastner"	},
		{ k_town_death, "hexx"	},
		{ k_town_death, "hsine"	},
		{ k_town_death, "jarvis"	},
		{ k_town_death, "jessika"	},
		{ k_town_death, "kurtos"	},
		{ k_town_death, "lamentia"	},
		{ k_town_death, "luna"	},
		{ k_town_death, "malafar"	},
		{ k_town_death, "malustar"	},
		{ k_town_death, "masqua"	},
		{ k_town_death, "mezizto"	},
		{ k_town_death, "moander"	},
		{ k_town_death, "oddrema"	},
		{ k_town_death, "panur"	},
		{ k_town_death, "paskovich"	},
		{ k_town_death, "rab"	},
		{ k_town_death, "reeva"	},
		{ k_town_death, "sandro"	},
		{ k_town_death, "sark"	},
		{ k_town_death, "shriek"	},
		{ k_town_death, "straker"	},
		{ k_town_death, "tamika"	},
		{ k_town_death, "thessa"	},
		{ k_town_death, "vidomina"	},
		{ k_town_death, "vilexica"	},
		{ k_town_death, "winsela"	},
		{ k_town_death, "xerxon"	},
		{ k_town_death, "yxia"	},
		{ k_town_death, "zaajuu"	},

		{ k_town_death, "sleeping"  },
		{ k_town_death, "dead"      },

		{ k_town_life,	"adelaide"	},
		{ k_town_life,	"araja"	},
		{ k_town_life,	"archimemnon"	},
		{ k_town_life,	"bakrus"	},
		{ k_town_life,	"bloomberg"	},
		{ k_town_life,	"caitlin"	},
		{ k_town_life,	"christian"	},
		{ k_town_life,	"corita"	},
		{ k_town_life,	"dallas"	},
		{ k_town_life,	"dalt"	},
		{ k_town_life,	"dorine"	},
		{ k_town_life,	"frini"	},
		{ k_town_life,	"gail"	},
		{ k_town_life,	"ingham"	},
		{ k_town_life,	"jerwall"	},
		{ k_town_life,	"julia"	},
		{ k_town_life,	"karth"	},
		{ k_town_life,	"kathleen"	},
		{ k_town_life,	"lemmar"	},
		{ k_town_life,	"leslie"	},
		{ k_town_life,	"marcius"	},
		{ k_town_life,	"maureen"	},
		{ k_town_life,	"michael"	},
		{ k_town_life,	"mierna"	},
		{ k_town_life,	"mirlanda"	},
		{ k_town_life,	"nanette"	},
		{ k_town_life,	"nevon"	},
		{ k_town_life,	"olwa"	},
		{ k_town_life,	"orlain"	},
		{ k_town_life,	"orrin"	},
		{ k_town_life,	"oyssin"	},
		{ k_town_life,	"pirvian"	},
		{ k_town_life,	"proetho"	},
		{ k_town_life,	"rex mundi"	},
		{ k_town_life,	"rion"	},
		{ k_town_life,	"sanya"	},
		{ k_town_life,	"sigrid"	},
		{ k_town_life,	"sir mullich"	},
		{ k_town_life,	"sorsha"	},
		{ k_town_life,	"tamara"	},
		{ k_town_life,	"thera"	},
		{ k_town_life,	"tyris"	},
		{ k_town_life,	"valli"	},
		{ k_town_life,	"valoryn"	},
		{ k_town_life,	"verdish"	},
		{ k_town_life,	"virgil"	},
		{ k_town_life,	"winifred"	},
		{ k_town_life,	"zambu"	},

		{ k_town_might,	"abegga"	},
		{ k_town_might,	"bofmog"	},
		{ k_town_might,	"bron"	},
		{ k_town_might,	"colwa"	},
		{ k_town_might,	"crag hack"	},
		{ k_town_might,	"dogwoggle"	},
		{ k_town_might,	"drenka"	},
		{ k_town_might,	"hagnar"	},
		{ k_town_might,	"jadne"	},
		{ k_town_might,	"khorrun"	},
		{ k_town_might,	"krellion"	},
		{ k_town_might,	"lanya"	},
		{ k_town_might,	"mick"	},
		{ k_town_might,	"nef"	},
		{ k_town_might,	"oroon"	},
		{ k_town_might,	"ranella"	},
		{ k_town_might,	"shiva"	},
		{ k_town_might,	"tazar"	},
		{ k_town_might,	"toadeater"	},
		{ k_town_might,	"trome"	},
		{ k_town_might,	"vix"	},
		{ k_town_might,	"wegg"	},
		{ k_town_might,	"yog"	},
		{ k_town_might,	"yutena"	},

		{ k_town_nature,	"aeris"	},
		{ k_town_nature,	"aleta"	},
		{ k_town_nature,	"anium"	},
		{ k_town_nature,	"arebell"	},
		{ k_town_nature,	"avanine"	},
		{ k_town_nature,	"blackdog"	},
		{ k_town_nature,	"braebar"	},
		{ k_town_nature,	"brook"	},
		{ k_town_nature,	"callis"	},
		{ k_town_nature,	"coronius"	},
		{ k_town_nature,	"derden"	},
		{ k_town_nature,	"eleece"	},
		{ k_town_nature,	"Elleshar"	},
		{ k_town_nature,	"enathrae"	},
		{ k_town_nature,	"erensar"	},
		{ k_town_nature,	"farnivon"	},
		{ k_town_nature,	"fatrim"	},
		{ k_town_nature,	"gem"	},
		{ k_town_nature,	"gill"	},
		{ k_town_nature,	"gue"	},
		{ k_town_nature,	"gwedmyr"	},
		{ k_town_nature,	"ignatius"	},
		{ k_town_nature,	"ilia"	},
		{ k_town_nature,	"iscandel"	},
		{ k_town_nature,	"ivor"	},
		{ k_town_nature,	"jenova"	},
		{ k_town_nature,	"kaliki"	},
		{ k_town_nature,	"kamiana"	},
		{ k_town_nature,	"kyrre"	},
		{ k_town_nature,	"labetha"	},
		{ k_town_nature,	"lindette"	},
		{ k_town_nature,	"lowell"	},
		{ k_town_nature,	"melodia"	},
		{ k_town_nature,	"mephala"	},
		{ k_town_nature,	"merlith"	},
		{ k_town_nature,	"neska"	},
		{ k_town_nature,	"oris"	},
		{ k_town_nature,	"pyral"	},
		{ k_town_nature,	"regina"	},
		{ k_town_nature,	"ryland"	},
		{ k_town_nature,	"saleena"	},
		{ k_town_nature,	"sannah"	},
		{ k_town_nature,	"shyn"	},
		{ k_town_nature,	"theritos"	},
		{ k_town_nature,	"tonwen"	},
		{ k_town_nature,	"trinni"	},
		{ k_town_nature,	"vialle"	},
		{ k_town_nature,	"yesterfox"	},

		{ k_town_order,	"abagael"	},
		{ k_town_order,	"aenain"	},
		{ k_town_order,	"aine"	},
		{ k_town_order,	"alem"	},
		{ k_town_order,	"astral"	},
		{ k_town_order,	"aycora"	},
		{ k_town_order,	"brendemar"	},
		{ k_town_order,	"brissa"	},
		{ k_town_order,	"calyphona"	},
		{ k_town_order,	"cyra"	},
		{ k_town_order,	"danika"	},
		{ k_town_order,	"daremyth"	},
		{ k_town_order,	"davius"	},
		{ k_town_order,	"fafner"	},
		{ k_town_order,	"fynelda"	},
		{ k_town_order,	"grindan"	},
		{ k_town_order,	"grum"	},
		{ k_town_order,	"grunkie"	},
		{ k_town_order,	"gurvilin"	},
		{ k_town_order,	"hally"	},
		{ k_town_order,	"hedegraus"	},
		{ k_town_order,	"iona"	},
		{ k_town_order,	"jubal"	},
		{ k_town_order,	"malcom"	},
		{ k_town_order,	"melody"	},
		{ k_town_order,	"merrox"	},
		{ k_town_order,	"minasli"	},
		{ k_town_order,	"mudgeon"	},
		{ k_town_order,	"neela"	},
		{ k_town_order,	"nobblenot"	},
		{ k_town_order,	"oaryn"	},
		{ k_town_order,	"olivaster"	},
		{ k_town_order,	"petula"	},
		{ k_town_order,	"piquedram"	},
		{ k_town_order,	"qubar"	},
		{ k_town_order,	"raven"	},
		{ k_town_order,	"redwar"	},
		{ k_town_order,	"rissa"	},
		{ k_town_order,	"segwen"	},
		{ k_town_order,	"sharah"	},
		{ k_town_order,	"solymr"	},
		{ k_town_order,	"suzieque"	},
		{ k_town_order,	"teddor"	},
		{ k_town_order,	"theodorus"	},
		{ k_town_order,	"tina"	},
		{ k_town_order,	"ufretin"	},
		{ k_town_order,	"urnaka"	},
		{ k_town_order,	"verno"	},

		/* Campaign heroes */
		{ k_town_chaos,  "tawni_balfour" },
		{ k_town_chaos,  "cyrca" },
		{ k_town_chaos,  "pete_girly" },
		{ k_town_nature, "elwin" },
		{ k_town_nature, "gramin" },
		{ k_town_nature, "lord_harke" },
		{ k_town_order,  "emilia_nighthaven" },
		{ k_town_order,  "gavin_magnus" },
		{ k_town_order,  "tharj" },
		{ k_town_order,  "genevieve" },
		{ k_town_order,  "pherlon" },
		{ k_town_life,   "lord_lysander" },
		{ k_town_life,   "desette" },
		{ k_town_life,   "kentaine" },
		{ k_town_life,   "worton" },
		{ k_town_might,  "waerjak" },
		{ k_town_death,  "suraze" },
		{ k_town_death,  "gauldoth" }, 
		{ k_town_death,  "kalibarr" }, 
		{ k_town_chaos,  "swift" },

		/* More General Use heroes */
		{ k_town_nature, "snowjay" },
		{ k_town_might,  "kel" },
		{ k_town_might,  "ferret" },
		{ k_town_life,	 "mardigo" },
		{ k_town_life,	 "nathaniel" },
		{ k_town_life,	 "equila" },
		{ k_town_life,	 "isabeau" },
		{ k_town_nature, "gathran" },
		{ k_town_order,	 "sylas zanj" },
		{ k_town_order,	 "paulus" },
		{ k_town_death,	 "baenefa" },
		{ k_town_death,	 "norticus" },
		{ k_town_death,	 "varduum" },
		{ k_town_chaos,	 "scorage" },
		{ k_town_chaos,	 "erica fade" },
		{ k_town_nature, "shaera" },
		
		// WARNING: Add only to the END of this array
	};

	t_bitmap_pool const k_hero_images( g_bitmap_cache, k_definitions, 
		                               ELEMENTS_OF( k_definitions ));
	t_bitmap_pool const k_hero_82_images( g_bitmap_82_cache, k_definitions, 
		                               ELEMENTS_OF( k_definitions ));

}; // unnammed namespace


int find_hero_portrait( std::string const& name )
{
	return k_hero_images.find( name );
}

t_bitmap_layer_ptr get_hero_portrait( int id, int height )
{
	if (height < 82)
		return k_hero_images.get( id );
	return k_hero_82_images.get( id );
}

int get_hero_portrait_count()
{
	return ELEMENTS_OF( k_definitions );
}

t_bitmap_layer_ptr get_dead_portrait( int height )
{
	static int  id = 0;
	static bool initialized = false;

	if (!initialized)
	{
		id = find_hero_portrait( "dead" );
		initialized = true;
	}
	return get_hero_portrait( id, height );
}
